import cv2
import numpy as np
from matplotlib import pyplot as plt

img1 = cv2.imread(r"C:\Users\Public\opencv\Figure\lena.png")

# x方向移动80像素，y方向移动40像素
M = np.float32([[1,0,80],[0,1,40]]) #构造矩阵M

rows,cols = img1.shape[0:2]

img2 = cv2.warpAffine(img1, M, (2*cols,2*rows))

img3 = cv2.resize(img1, None,fx=0.6,fy=0.6,interpolation=cv2.INTER_CUBIC)

plt.subplot(131),plt.imshow(img1)
plt.subplot(132),plt.imshow(img2)
plt.subplot(133),plt.imshow(img3)

cv2.waitKey(0)
cv2.destroyAllWindows()
